package com.gitee.vincentzyu.qwq_forge189.common;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.BlockPos;
import net.minecraft.util.ChatComponentText;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.EventBus;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent;

public class EventLoader {

    public static final EventBus EVENT_BUS = new EventBus();

    public EventLoader(){
        MinecraftForge.EVENT_BUS.register(this);
    }


    @SubscribeEvent
    public void onPlayerItemPickup(PlayerEvent.ItemPickupEvent e){
        if ( e.player.isServerWorld() ){
            String info = String.format("%s picks up: %s", e.player.getName(), e.pickedUp.getEntityItem());
            e.player.addChatMessage(new ChatComponentText("【qwq】吸！"));
        }
    }

    @SubscribeEvent
    public void onQwq(QwqEvent e){
        if ( !e.world.isRemote ){
            e.entityPlayer.addChatMessage(new ChatComponentText("【qwq】你好 你右键了我"));
        }
    }

    @Cancelable
    public static class QwqEvent extends net.minecraftforge.event.entity.player.PlayerEvent{
        public final BlockPos pos;
        public final World world;

        public QwqEvent(EntityPlayer player, BlockPos pos, World world){
            super(player);
            this.pos = pos;
            this.world = world;
        }
    }

    @SubscribeEvent
    public void onPlayerQueryAchievements(PlayerQueryAchievementsEvent e){
        //todo
    }

    @Cancelable
    public static class PlayerQueryAchievementsEvent extends net.minecraftforge.event.entity.player.PlayerEvent{
        public final BlockPos pos;
        public final World world;

        public PlayerQueryAchievementsEvent(EntityPlayer player, BlockPos pos, World world){
            super(player);
            this.pos = pos;
            this.world = world;
        }
    }
}
